package com.lemt.user.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.lemt.user.entity.Role;
import com.lemt.user.service.IRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zik
 * @since 2023-09-10
 */
@Api(tags = "角色管理")
@RestController
@RequestMapping("/role")
public class RoleController {

    @Resource(name = "IRoleService")
    private IRoleService roleService;

    @ApiOperation(value = "保存角色")
    @ApiOperationSupport(includeParameters = {"role.roleName"})
    @PostMapping("/saveRole")
    public Boolean addMeau(@RequestBody Role role){
        return roleService.save(role);
    }

    @ApiOperation(value = "删除角色")
    @ApiOperationSupport(includeParameters = {"role.id"})
    @DeleteMapping("/removeRoleById")
    public Boolean remove(@RequestBody Role role) {
        return roleService.removeById(role);
    }

    @ApiOperation(value = "修改角色名")
    @ApiOperationSupport(ignoreParameters = {"role.createTime"})
    @PostMapping("/updateRoleById")
    public Boolean update(@RequestBody Role role){
        return  roleService.updateById(role);
    }

    @ApiOperation(value = "获取所有角色")
    @GetMapping("/list")
    public List<Role> list() {
        return roleService.list();
    }

}
